<?php

/**
 * 默认接口服务类
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */
class Api_Response extends PhalApi_Api
{

    public function getRules()
    {
        return array(
            'listResponse' => array(
                'doctor_id' => array('name' => 'DoctorId', 'require' => true)
            ),
            'getResponse' => array(
                'response_id' => array('name' => 'ResponseId', 'require' => true)
            ),
            'listDoctorOfResponse'=>array(
                'event_id'=>array('name'=>'EventId','require'=>true),
                'lng'=>array('name'=>'Lng','require'=>true),
                'lat'=>array('name'=>'Lat','require'=>true),
            )
        );
    }

    /**
     * 呼叫信息列表
     * @desc 呼叫信息列表
     * @return int code 操作码，0表示成功， 1错误
     * @return object info 信息对象
     * @return string msg 提示信息
     */
    public function listResponse()
    {
        $rs = array('code' => 0, 'msg' => '', 'info' => array());

        $domain = new Domain_Response();
        $info = $domain->listResponse($this->doctor_id);

        if (empty($info)) {
            DI()->logger->debug('listResponse()', '');

            $rs['code'] = 1;
            $rs['msg'] = T('没有呼叫信息');
            return $rs;
        }

        $rs['info'] = $info;
        DI()->logger->debug('info of listResponse()', $rs);

        return $rs;

    }

    /**
     * 获取呼叫信息详情
     * @desc 获取呼叫信息详情
     * @return int code 操作码，0表示成功， 1错误
     * @return object info 信息对象
     * @return string msg 提示信息
     */
    public function getResponse()
    {
        $rs = array('code' => 0, 'msg' => '', 'info' => array());

        $domain = new Domain_Response();
        $info = $domain->getResponse($this->response_id);

        if (empty($info)) {
            DI()->logger->debug('getResponse()', '');

            $rs['code'] = 1;
            $rs['msg'] = T('获取呼叫信息详情失败');
            return $rs;
        }

        $rs['info'] = $info;
        DI()->logger->debug('info of getResponse()', $rs);

        return $rs;

    }
    /**
         * 获取被呼叫的医生列表
         * @desc 添加了医生距离
         * @return int code 操作码，0表示成功， 1错误
         * @return object info 信息对象
         * @return string msg 提示信息
         */
    public function listDoctorOfResponse() {
            $rs = array('code' => 0, 'msg' => '', 'info' =>array('a'=>1));
    
            $domain = new Domain_Response();
            $info = $domain->listDoctorOfResponse($this->event_id,$this->lng,$this->lat);
    
            if (empty($info)) {
                DI()->logger->debug('listDoctorOfResponse()','');
    
                $rs['code'] = 1;
                $rs['msg'] = T('没有被呼叫的医生');
                return $rs;
            }
    
            $rs['info'] = $info;
            DI()->logger->debug('info of listDoctorOfResponse()', $rs);
    
            return $rs;
    
        }

}